package com.xhcl.web.controller.system;

import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.xhcl.common.annotation.Log;
import com.xhcl.common.enums.BusinessType;
import com.xhcl.system.domain.TGgSjtb;
import com.xhcl.system.service.ITGgSjtbService;
import com.xhcl.common.core.controller.BaseController;
import com.xhcl.common.core.domain.AjaxResult;
import com.xhcl.framework.uitls.poi.ExcelUtil;
import com.xhcl.common.core.page.TableDataInfo;

/**
 * 数据同步Controller
 * 
 * @author xhcl
 * @date 2020-09-02
 */
@Controller
@RequestMapping("/system/sjtb")
public class TGgSjtbController extends BaseController
{
    private String prefix = "system/sjtb";

    @Autowired
    private ITGgSjtbService tGgSjtbService;

    @RequiresPermissions("system:sjtb:view")
    @GetMapping()
    public String sjtb()
    {
        return prefix + "/sjtb";
    }

    /**
     * 查询数据同步列表
     */
    @RequiresPermissions("system:sjtb:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TGgSjtb tGgSjtb)
    {
        startPage();
        List<TGgSjtb> list = tGgSjtbService.selectTGgSjtbList(tGgSjtb);
        return getDataTable(list);
    }

    /**
     * 导出数据同步列表
     */
    @RequiresPermissions("system:sjtb:export")
    @Log(title = "数据同步", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TGgSjtb tGgSjtb)
    {
        List<TGgSjtb> list = tGgSjtbService.selectTGgSjtbList(tGgSjtb);
        ExcelUtil<TGgSjtb> util = new ExcelUtil<TGgSjtb>(TGgSjtb.class);
        return util.exportExcel(list, "sjtb");
    }

    /**
     * 新增数据同步
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存数据同步
     */
    @RequiresPermissions("system:sjtb:sync")
    @Log(title = "数据同步", businessType = BusinessType.UPDATE)
    @PostMapping("/sync")
    @ResponseBody
    public AjaxResult sync(TGgSjtb tGgSjtb)
    {
    	
    	tGgSjtbService.sync(tGgSjtb.getLsh(), tGgSjtb.getRemark());
        return AjaxResult.success();
    }

    
}
